package com.getword.utils;

import com.getword.domain.User;
import com.getword.security.SUser;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;

@Component
public class SpringContextUtil {

    public static User getLoginUser(){
        SUser user = (SUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        return new User(user.getUserId(), user.getUsername(), user.getName());
    }
}
